import { BasicColumn, FormSchema } from '/@/components/Table';
import { h } from 'vue';
import { Tag } from 'ant-design-vue';
export const columns: BasicColumn[] = [
  {
    title: '充电线路',
    dataIndex: 'line',
    align: 'center',
    width: 120,
  },
  {
    title: '电表地址',
    dataIndex: 'addr',
    align: 'center',
    width: 120,
  },
  {
    title: '网关IP',
    dataIndex: 'ip',
    align: 'center',
    width: 180,
  },
  {
    title: '网关端口号',
    dataIndex: 'port',
    align: 'center',
    width: 120,
  },
  {
    title: '房间号',
    dataIndex: 'room',
    align: 'center',
    width: 120,
  },
  {
    title: 'useage',
    dataIndex: 'useage',
    align: 'center',
    width: 180,
  },
  {
    title: '控制尝试次数',
    dataIndex: 'times',
    align: 'center',
    width: 180,
  },
  {
    title: '类型',
    dataIndex: 'state',
    align: 'center',
    width: 120,
    customRender: ({ text }) => {
      return h(Tag, { color: 'green' }, () => (text == 1 ? '常亮宿舍' : text == 2 ? '熄灯宿舍' : '--'));
    },
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'ip',
    label: '网关IP',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'room',
    label: '房间号',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'state',
    label: '宿舍类型',
    component: 'RadioGroup',
    componentProps: {
      //options里面由一个一个的radio组成,支持disabled禁用
      options: [
        { label: '常亮宿舍,', value: 1 },
        { label: '熄灯宿舍', value: 2 },
      ],
    },
    colProps: { span: 6 },
  },
];

export const formSchema: FormSchema[] = [
  {
    label: '序号（did）',
    field: 'did',
    component: 'Input',
  },
  {
    label: '充电线路',
    field: 'line',
    component: 'Input',
  },
  {
    label: '电表地址',
    field: 'addr',
    component: 'Input',
  },
  {
    label: '网关IP',
    field: 'ip',
    component: 'Input',
  },
  {
    label: '网关端口号',
    field: 'port',
    component: 'Input',
  },
  {
    label: '房间号',
    field: 'room',
    component: 'Input',
  },
  {
    label: '控制尝试次数',
    field: 'times',
    component: 'InputNumber',
  },
  {
    label: 'useage',
    field: 'useage',
    component: 'Input',
  },
  {
    label: '类型',
    field: 'state',
    component: 'RadioButtonGroup',
    componentProps: {
      options: [
        { label: '常亮宿舍', value: 1 },
        { label: '熄灯宿舍', value: 2 },
      ],
    },
  },
];
